package com.ts.api.http.platform.biz;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gitee.apanlh.util.algorithm.encrypt.symmetric.AES;
import com.gitee.apanlh.util.base.*;
import com.gitee.apanlh.util.dataformat.JsonUtils;
import com.gitee.apanlh.util.valid.ValidParam;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.ts.api.common.util.H5DomainUrlUtils;
import com.ts.api.http.platform.entity.apply.ApiPlatApplyFangXinJie;
import com.ts.api.http.platform.entity.dataexchange.ApiPlatDataExchangeFangXinJie;
import com.ts.api.module.api.convert.core.annotation.ApiPlan;
import com.ts.api.module.api.convert.core.annotation.ApiPlanConvertType;
import com.ts.api.module.api.convert.core.entity.ApiApplyParameter;
import com.ts.api.module.api.convert.core.entity.ApiBizStatus;
import com.ts.api.module.api.convert.core.entity.ApiDataExchangeParameter;
import com.ts.api.module.api.convert.core.utils.ApiFieldConverter;
import com.ts.api.module.api.convert.platform.entity.RespPlatformMultiPhoneMaskDataExchange;
import com.ts.api.module.api.convert.platform.entity.RespPlatformNoticeApply;
import com.ts.api.module.api.convert.platform.entity.RespPlatformPhoneMaskApply;
import com.ts.api.module.api.convert.platform.entity.RespPlatformPhoneMaskDataExchange;
import com.ts.api.module.api.convert.platform.handler.ApiPlatformPhoneMaskConvertHandler;
import com.ts.api.module.api.entity.ApiProtocol;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 安心分期出放心借分期全28分掩码
 * https://docs.apipost.net/docs/4bda50d518e1000?locale=zh-cn 采量掩码
 *
 * @author WJB
 */
@ApiPlan(productId = "412", type = ApiPlanConvertType.PLAT_PHONE_MASK)
public class ApiPlatFangXinJiePhoneMask implements ApiPlatformPhoneMaskConvertHandler {

    public static final String KEY = "KOMWqzX1H7vIbELi";
    public static final String CHANNEL_CODE = "Jv61pTZmcp";

    @Override
    public Object dataExchange(ApiDataExchangeParameter apiDataExchangeParameter) throws Exception {
        //  创建对应撞库实体类
        ApiPlatDataExchangeFangXinJie data = new ApiPlatDataExchangeFangXinJie();
        ApiFieldConverter apiFieldConverter = ApiFieldConverter.create(apiDataExchangeParameter);
        //  8位明文手机号
        data.setPhone_mask(apiDataExchangeParameter.getPhoneMask());
        data.setName("测试用户");
        data.setAge(apiFieldConverter.getAgeInt());
        //  性别 1男 2女
        Integer sex = ChooseEq.create()
                .when(apiDataExchangeParameter.getSex(), "1", 2)
                .when(apiDataExchangeParameter.getSex(), "0", 1)
                .end(1);
        data.setSex(sex);
        //  省份
        data.setProvince(apiDataExchangeParameter.getProvinceName());
        //  城市
        data.setCity(apiDataExchangeParameter.getCity());
        //  职业。1-上班族。2-企业主。3-个体户。4-自由职业。5-事业单位/公务员
        Integer job = ChooseEq.create()
                .when(apiDataExchangeParameter.getCareer(), "1", 1)
                .when(apiDataExchangeParameter.getCareer(), "2", 4)
                .when(apiDataExchangeParameter.getCareer(), "3", 2)
                .when(apiDataExchangeParameter.getCareer(), "4", 5)
                .when(apiDataExchangeParameter.getCareer(), "5", 3)
                .end(1);
        data.setOccupation(job);
        //  学历。1- 小学。2- 初中。3- 高中。4-中专。5-专科。6-本科 。7-博士研究生
        Integer educationAttainment = ChooseEq.create()
                .when(apiDataExchangeParameter.getEducationAttainment(), "1", 2)
                .when(apiDataExchangeParameter.getEducationAttainment(), "2", 4)
                .when(apiDataExchangeParameter.getEducationAttainment(), "3", 3)
                .when(apiDataExchangeParameter.getEducationAttainment(), "4", 5)
                .when(apiDataExchangeParameter.getEducationAttainment(), "5", 6)
                .when(apiDataExchangeParameter.getEducationAttainment(), "6", 7)
                .end(1);
        data.setEducation(educationAttainment);
        //  社保。1-无社保。2-未满六个月。3-六个月以上
        Integer shebao = ChooseEq.create()
                .when(apiDataExchangeParameter.getSocialSecurity(), "1", 1)
                .when(apiDataExchangeParameter.getSocialSecurity(), "2", 2)
                .when(apiDataExchangeParameter.getSocialSecurity(), "3", 3)
                .when(apiDataExchangeParameter.getSocialSecurity(), "4", 2)
                .end(1);
        data.setSocial_security(shebao);
        //  公积金。1-无公积金。2-未满六个月。3-六个月以上
        Integer gongjijin = ChooseEq.create()
                .when(apiDataExchangeParameter.getProvidentFund(), "1", 1)
                .when(apiDataExchangeParameter.getProvidentFund(), "2", 2)
                .when(apiDataExchangeParameter.getProvidentFund(), "3", 3)
                .when(apiDataExchangeParameter.getProvidentFund(), "4", 2)
                .end(1);
        data.setAccumulation_fund(gongjijin);
        //  房产 。1-无房产。2-按揭房。3-全款房不接受抵押。4-全款房接受抵押
        Integer house = ChooseEq.create()
                .when(apiDataExchangeParameter.getRealEstateInfo(), "1", 1)
                .when(apiDataExchangeParameter.getRealEstateInfo(), "2", 3)
                .when(apiDataExchangeParameter.getRealEstateInfo(), "3", 4)
                .when(apiDataExchangeParameter.getRealEstateInfo(), "4", 2)
                .when(apiDataExchangeParameter.getRealEstateInfo(), "5", 2)
                .when(apiDataExchangeParameter.getRealEstateInfo(), "6", 3)
                .end(1);
        data.setHouse(house);
        //  车辆。1- 无车辆。2-按揭车。3-全款车不接受抵押。4-全款车接受抵押
        Integer car = ChooseEq.create()
                .when(apiDataExchangeParameter.getCarInfo(), "1", 1)
                .when(apiDataExchangeParameter.getCarInfo(), "2", 3)
                .when(apiDataExchangeParameter.getCarInfo(), "3", 4)
                .when(apiDataExchangeParameter.getCarInfo(), "4", 2)
                .end(1);
        data.setCar(car);
        //  保险 。1-未买保险。2-缴纳满一年。3-缴纳一年以上
        Integer baodanIs = ChooseEq.create()
                .when(apiDataExchangeParameter.getInsurancePolicy(), "1", 1)
                .when(apiDataExchangeParameter.getInsurancePolicy(), "2", 2)
                .when(apiDataExchangeParameter.getInsurancePolicy(), "3", 3)
                .when(apiDataExchangeParameter.getInsurancePolicy(), "4", 2)
                .end(1);
        data.setInsurance(baodanIs);
        //  芝麻分。1-无芝麻分。2-600分以下。3-601-649分。4-650-700分。5-700分以上
        Integer zhima = ChooseEq.create()
                .when(apiDataExchangeParameter.getSesameCredit(), "1", 2)
                .when(apiDataExchangeParameter.getSesameCredit(), "2", 3)
                .when(apiDataExchangeParameter.getSesameCredit(), "3", 4)
                .when(apiDataExchangeParameter.getSesameCredit(), "4", 5)
                .end(1);
        data.setSesame(zhima);
        //  京东白条额度。1-无。2-5000以上。3-5000以下
        Integer btLimit = ChooseEq.create()
                .when(apiDataExchangeParameter.getBtLimit(), "1", 1)
                .when(apiDataExchangeParameter.getBtLimit(), "2", 3)
                .when(apiDataExchangeParameter.getBtLimit(), "3", 2)
                .when(apiDataExchangeParameter.getBtLimit(), "4", 2)
                .when(apiDataExchangeParameter.getBtLimit(), "5", 2)
                .end(1);
        data.setBaitiao(btLimit);
        //  花呗额度。1-无。2-5000以上。3-5000以下
        Integer hbLimit = ChooseEq.create()
                .when(apiDataExchangeParameter.getHbLimit(), "1", 1)
                .when(apiDataExchangeParameter.getHbLimit(), "2", 3)
                .when(apiDataExchangeParameter.getHbLimit(), "3", 2)
                .when(apiDataExchangeParameter.getHbLimit(), "4", 2)
                .when(apiDataExchangeParameter.getHbLimit(), "5", 2)
                .end(1);
        data.setHuabei(hbLimit);
        data.setWeilidai(1);
        //  逾期情况。1-信用良好无逾期 。2-信用卡或贷款存在逾期。3-1年内有逾期 。4-1年内无逾期
        Integer overdue = ChooseEq.create()
                .when(apiDataExchangeParameter.getOverdue(), "1", 1)
                .when(apiDataExchangeParameter.getOverdue(), "2", 2)
                .when(apiDataExchangeParameter.getOverdue(), "3", 4)
                .end(1);
        data.setOverdue(overdue);
        //  信用卡。1-无。2-有
        Integer creditLimit = ChooseEq.create(apiDataExchangeParameter.getCreditLimit())
                .when("1", 1)
                .when("2", 2)
                .when("3", 2)
                .when("4", 2)
                .when("5", 2)
                .when("6", 2)
                .end(1);
        data.setCredit_card(creditLimit);
        //  贷款金额。1、1-3万。2、3-5万。3、5-10万。4、10-20万。5、20万以上
        Integer money = ChooseEq.create()
                .when(apiDataExchangeParameter.getLoanAmount(), "1", 1)
                .when(apiDataExchangeParameter.getLoanAmount(), "2", 3)
                .when(apiDataExchangeParameter.getLoanAmount(), "3", 4)
                .when(apiDataExchangeParameter.getLoanAmount(), "4", 5)
                .end(1);
        data.setLoan_amount(money);
        //  贷款时间。1、1-3个月2、3-6个月。3、6-12个月。4、12个月以上
        Integer loanTerm = ChooseEq.create()
                .when(apiDataExchangeParameter.getLoanTerm(), "1", 1)
                .when(apiDataExchangeParameter.getLoanTerm(), "2", 2)
                .when(apiDataExchangeParameter.getLoanTerm(), "3", 4)
                .when(apiDataExchangeParameter.getLoanTerm(), "4", 4)
                .when(apiDataExchangeParameter.getLoanTerm(), "5", 4)
                .when(apiDataExchangeParameter.getLoanTerm(), "6", 4)
                .end(1);
        data.setLoan_time(loanTerm);
        //  月收入。1、1-5000元。2、5000-10000元。3、10000-20000元。4、20000元以上
        Integer monthlySalary = ChooseEq.create()
                .when(apiDataExchangeParameter.getMonthlySalary(), "1", 1)
                .when(apiDataExchangeParameter.getMonthlySalary(), "2", 2)
                .when(apiDataExchangeParameter.getMonthlySalary(), "3", 3)
                .when(apiDataExchangeParameter.getMonthlySalary(), "4", 4)
                .when(apiDataExchangeParameter.getMonthlySalary(), "5", 4)
                .end(1);
        data.setMonth_income(monthlySalary);
        //  营业执照。1、有 。2、无
        Integer bizLicenseYear = ChooseEq.create()
                .when(apiDataExchangeParameter.getBizLicenseYear(), "1", 2)
                .when(apiDataExchangeParameter.getBizLicenseYear(), "2", 1)
                .when(apiDataExchangeParameter.getBizLicenseYear(), "3", 1)
                .when(apiDataExchangeParameter.getBizLicenseYear(), "4", 1)
                .end(2);
        data.setBusiness_license(bizLicenseYear);
        data.setRequest_id(apiDataExchangeParameter.getReqId());
        //  IP
        if (ValidParam.isNotEmpty(apiDataExchangeParameter.getIp())) {
            data.setClient_ip(apiDataExchangeParameter.getIp());
        } else {
            data.setClient_ip("127.0.0.1");
        }
        //  加密
        AES aes = AES.createEcb(KEY.getBytes());
        Map<String, Object> map = MapUtils.newHashMap(newMap -> {
            newMap.put("channel_code", CHANNEL_CODE);
            newMap.put("data", aes.encryptToBase64Str(JsonUtils.toJson(data)));
        });
        return JsonUtils.toJson(map);
    }

    @Override
    public RespPlatformMultiPhoneMaskDataExchange respDataExchange(String respJson) throws Exception {
        JSONObject jsonObject = JsonUtils.get(respJson);
        if (jsonObject == null) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }
        if (!Eq.object(jsonObject.getInteger("code"), 200)) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }
        JSONArray resData = JsonUtils.get(respJson).getJSONArray("result");
        if (ValidParam.isEmpty(resData)) {
            return RespPlatformMultiPhoneMaskDataExchange.ofFail();
        }

        RespPlatformMultiPhoneMaskDataExchange respPlatformMultiPhoneMaskDataExchange = RespPlatformMultiPhoneMaskDataExchange.ofSuc();
        List<RespPlatformPhoneMaskDataExchange> listRespPlatformPhoneMaskDataExchange = CollUtils.newArrayList();

        for (int i = 0; i < resData.size(); i++) {
            JSONObject item = resData.getJSONObject(i);
            if (ValidParam.isNotNull(item)) {
                //  缺失用户协议
                BigDecimal price = item.getBigDecimal("price");
                String logo = item.getString("agency_logo");
                String productNo = item.getString("product_no");
                String companyName = item.getString("agency_name");
                String productName = item.getString("product_name");

                //  用户协议
                List<ApiProtocol> protocolList = CollUtils.newArrayList(newList -> {
                    //  获取协议
                    JSONArray listProtocolResult = item.getJSONArray("Agreement");
                    IteratorUtils.array(listProtocolResult, (protocolResult, index) -> {
                        JSONObject protocolObject = listProtocolResult.getJSONObject(index);
                        ApiProtocol protocol = new ApiProtocol();
                        protocol.setProtocolName(protocolObject.getString("name"));
                        protocol.setProtocolUrl(protocolObject.getString("url"));
                        newList.add(protocol);
                    });
                });

                //  获取手机号掩码
                List<String> listPhoneMd5 = new ArrayList<>();
                JSONArray jsonArray = item.getJSONArray("phone_md5_lists");
                IteratorUtils.array(jsonArray, (listMd5, index) -> {
                    String phoneMd5 = jsonArray.getString(index);
                    listPhoneMd5.add(phoneMd5);
                });
                RespPlatformPhoneMaskDataExchange result = RespPlatformPhoneMaskDataExchange.of();

                result.setPrice(price);
                result.setLogoPath(logo);
                result.setApplyId(productNo);
                result.setDisplayName(companyName);
                result.setProductName(productName);
                result.setProtocolList(protocolList);
                result.setListPhoneMd5(listPhoneMd5);
                listRespPlatformPhoneMaskDataExchange.add(result);
            }
        }

        respPlatformMultiPhoneMaskDataExchange.setListPhoneMask(listRespPlatformPhoneMaskDataExchange);
        return respPlatformMultiPhoneMaskDataExchange;
    }

    @Override
    public Object apply(ApiApplyParameter apiApplyParameter) throws Exception {
        //  创建对应进件实体类
        ApiPlatApplyFangXinJie data = new ApiPlatApplyFangXinJie();
        ApiFieldConverter apiFieldConverter = ApiFieldConverter.create(apiApplyParameter);
        //  8位明文手机号
        data.setPhone(apiApplyParameter.getPhone());
        data.setName(apiApplyParameter.getUserName());
        data.setAge(apiFieldConverter.getAgeInt());
        //  性别 1男 2女
        Integer sex = ChooseEq.create()
                .when(apiApplyParameter.getSex(), "1", 2)
                .when(apiApplyParameter.getSex(), "0", 1)
                .end(1);
        data.setSex(sex);
        //  省份
        data.setProvince(apiApplyParameter.getProvinceName());
        //  城市
        data.setCity(apiApplyParameter.getCity());
        //  职业。1-上班族。2-企业主。3-个体户。4-自由职业。5-事业单位/公务员
        Integer job = ChooseEq.create()
                .when(apiApplyParameter.getCareer(), "1", 1)
                .when(apiApplyParameter.getCareer(), "2", 4)
                .when(apiApplyParameter.getCareer(), "3", 2)
                .when(apiApplyParameter.getCareer(), "4", 5)
                .when(apiApplyParameter.getCareer(), "5", 3)
                .end(1);
        data.setOccupation(job);
        //  学历。1- 小学。2- 初中。3- 高中。4-中专。5-专科。6-本科 。7-博士研究生
        Integer educationAttainment = ChooseEq.create()
                .when(apiApplyParameter.getEducationAttainment(), "1", 2)
                .when(apiApplyParameter.getEducationAttainment(), "2", 4)
                .when(apiApplyParameter.getEducationAttainment(), "3", 3)
                .when(apiApplyParameter.getEducationAttainment(), "4", 5)
                .when(apiApplyParameter.getEducationAttainment(), "5", 6)
                .when(apiApplyParameter.getEducationAttainment(), "6", 7)
                .end(1);
        data.setEducation(educationAttainment);
        //  社保。1-无社保。2-未满六个月。3-六个月以上
        Integer shebao = ChooseEq.create()
                .when(apiApplyParameter.getSocialSecurity(), "1", 1)
                .when(apiApplyParameter.getSocialSecurity(), "2", 2)
                .when(apiApplyParameter.getSocialSecurity(), "3", 3)
                .when(apiApplyParameter.getSocialSecurity(), "4", 2)
                .end(1);
        data.setSocial_security(shebao);
        //  公积金。1-无公积金。2-未满六个月。3-六个月以上
        Integer gongjijin = ChooseEq.create()
                .when(apiApplyParameter.getProvidentFund(), "1", 1)
                .when(apiApplyParameter.getProvidentFund(), "2", 2)
                .when(apiApplyParameter.getProvidentFund(), "3", 3)
                .when(apiApplyParameter.getProvidentFund(), "4", 2)
                .end(1);
        data.setAccumulation_fund(gongjijin);
        //  房产 。1-无房产。2-按揭房。3-全款房不接受抵押。4-全款房接受抵押
        Integer house = ChooseEq.create()
                .when(apiApplyParameter.getRealEstateInfo(), "1", 1)
                .when(apiApplyParameter.getRealEstateInfo(), "2", 3)
                .when(apiApplyParameter.getRealEstateInfo(), "3", 4)
                .when(apiApplyParameter.getRealEstateInfo(), "4", 2)
                .when(apiApplyParameter.getRealEstateInfo(), "5", 2)
                .when(apiApplyParameter.getRealEstateInfo(), "6", 3)
                .end(1);
        data.setHouse(house);
        //  车辆。1- 无车辆。2-按揭车。3-全款车不接受抵押。4-全款车接受抵押
        Integer car = ChooseEq.create()
                .when(apiApplyParameter.getCarInfo(), "1", 1)
                .when(apiApplyParameter.getCarInfo(), "2", 3)
                .when(apiApplyParameter.getCarInfo(), "3", 4)
                .when(apiApplyParameter.getCarInfo(), "4", 2)
                .end(1);
        data.setCar(car);
        //  保险 。1-未买保险。2-缴纳满一年。3-缴纳一年以上
        Integer baodanIs = ChooseEq.create()
                .when(apiApplyParameter.getInsurancePolicy(), "1", 1)
                .when(apiApplyParameter.getInsurancePolicy(), "2", 2)
                .when(apiApplyParameter.getInsurancePolicy(), "3", 3)
                .when(apiApplyParameter.getInsurancePolicy(), "4", 2)
                .end(1);
        data.setInsurance(baodanIs);
        //  芝麻分。1-无芝麻分。2-600分以下。3-601-649分。4-650-700分。5-700分以上
        Integer zhima = ChooseEq.create()
                .when(apiApplyParameter.getSesameCredit(), "1", 2)
                .when(apiApplyParameter.getSesameCredit(), "2", 3)
                .when(apiApplyParameter.getSesameCredit(), "3", 4)
                .when(apiApplyParameter.getSesameCredit(), "4", 5)
                .end(1);
        data.setSesame(zhima);
        //  京东白条额度。1-无。2-5000以上。3-5000以下
        Integer btLimit = ChooseEq.create()
                .when(apiApplyParameter.getBtLimit(), "1", 1)
                .when(apiApplyParameter.getBtLimit(), "2", 3)
                .when(apiApplyParameter.getBtLimit(), "3", 2)
                .when(apiApplyParameter.getBtLimit(), "4", 2)
                .when(apiApplyParameter.getBtLimit(), "5", 2)
                .end(1);
        data.setBaitiao(btLimit);
        //  花呗额度。1-无。2-5000以上。3-5000以下
        Integer hbLimit = ChooseEq.create()
                .when(apiApplyParameter.getHbLimit(), "1", 1)
                .when(apiApplyParameter.getHbLimit(), "2", 3)
                .when(apiApplyParameter.getHbLimit(), "3", 2)
                .when(apiApplyParameter.getHbLimit(), "4", 2)
                .when(apiApplyParameter.getHbLimit(), "5", 2)
                .end(1);
        data.setHuabei(hbLimit);
        data.setWeilidai(1);
        //  逾期情况。1-信用良好无逾期 。2-信用卡或贷款存在逾期。3-1年内有逾期 。4-1年内无逾期
        Integer overdue = ChooseEq.create()
                .when(apiApplyParameter.getOverdue(), "1", 1)
                .when(apiApplyParameter.getOverdue(), "2", 2)
                .when(apiApplyParameter.getOverdue(), "3", 4)
                .end(1);
        data.setOverdue(overdue);
        //  信用卡。1-无。2-有
        Integer creditLimit = ChooseEq.create(apiApplyParameter.getCreditLimit())
                .when("1", 1)
                .when("2", 2)
                .when("3", 2)
                .when("4", 2)
                .when("5", 2)
                .when("6", 2)
                .end(1);
        data.setCredit_card(creditLimit);
        //  贷款金额。1、1-3万。2、3-5万。3、5-10万。4、10-20万。5、20万以上
        Integer money = ChooseEq.create()
                .when(apiApplyParameter.getLoanAmount(), "1", 1)
                .when(apiApplyParameter.getLoanAmount(), "2", 3)
                .when(apiApplyParameter.getLoanAmount(), "3", 4)
                .when(apiApplyParameter.getLoanAmount(), "4", 5)
                .end(1);
        data.setLoan_amount(money);
        //  贷款时间。1、1-3个月2、3-6个月。3、6-12个月。4、12个月以上
        Integer loanTerm = ChooseEq.create()
                .when(apiApplyParameter.getLoanTerm(), "1", 1)
                .when(apiApplyParameter.getLoanTerm(), "2", 2)
                .when(apiApplyParameter.getLoanTerm(), "3", 4)
                .when(apiApplyParameter.getLoanTerm(), "4", 4)
                .when(apiApplyParameter.getLoanTerm(), "5", 4)
                .when(apiApplyParameter.getLoanTerm(), "6", 4)
                .end(1);
        data.setLoan_time(loanTerm);
        //  月收入。1、1-5000元。2、5000-10000元。3、10000-20000元。4、20000元以上
        Integer monthlySalary = ChooseEq.create()
                .when(apiApplyParameter.getMonthlySalary(), "1", 1)
                .when(apiApplyParameter.getMonthlySalary(), "2", 2)
                .when(apiApplyParameter.getMonthlySalary(), "3", 3)
                .when(apiApplyParameter.getMonthlySalary(), "4", 4)
                .when(apiApplyParameter.getMonthlySalary(), "5", 4)
                .end(1);
        data.setMonth_income(monthlySalary);
        //  营业执照。1、有 。2、无
        Integer bizLicenseYear = ChooseEq.create()
                .when(apiApplyParameter.getBizLicenseYear(), "1", 2)
                .when(apiApplyParameter.getBizLicenseYear(), "2", 1)
                .when(apiApplyParameter.getBizLicenseYear(), "3", 1)
                .when(apiApplyParameter.getBizLicenseYear(), "4", 1)
                .end(2);
        data.setBusiness_license(bizLicenseYear);
        data.setRequest_id(apiApplyParameter.getReqId());
        data.setProduct_no(apiApplyParameter.getApplyId());
        //  IP
        if (ValidParam.isNotEmpty(apiApplyParameter.getIp())) {
            data.setClient_ip(apiApplyParameter.getIp());
        } else {
            data.setClient_ip("127.0.0.1");
        }
        //  授权协议
        ApiPlatApplyFangXinJie.Agreement agreement = new ApiPlatApplyFangXinJie.Agreement();
        agreement.setUrl(H5DomainUrlUtils.createUserProtocolUrl(apiApplyParameter.getProductPlanId(), apiApplyParameter.getPhoneMd5()));
        agreement.setName("用户授权协议");
        List<ApiPlatApplyFangXinJie.Agreement> list = new ArrayList<>();
        list.add(agreement);
        data.setAgreement(list);
        //  加密
        AES aes = AES.createEcb(KEY.getBytes());
        Map<String, Object> map = MapUtils.newHashMap(newMap -> {
            newMap.put("channel_code", CHANNEL_CODE);
            newMap.put("data", aes.encryptToBase64Str(JsonUtils.toJson(data)));
        });
        return JsonUtils.toJson(map);
    }

    @Override
    public RespPlatformPhoneMaskApply respApply(String respJson) throws Exception {
        JSONObject jsonObject = JsonUtils.get(respJson);
        if (jsonObject == null) {
            return RespPlatformPhoneMaskApply.ofFail();
        }
        if (!Eq.object(jsonObject.getInteger("code"), 200)) {
            return RespPlatformPhoneMaskApply.ofFail();
        }
        return RespPlatformPhoneMaskApply.ofSuc();
    }


    @Override
    public RespPlatformNoticeApply parseApplyNotice(RequestVO requestVO) {
        return null;
    }

    @Override
    public Map<String, Object> respApplyNotice(ApiBizStatus apiBizStatus) {
        return Map.of();
    }
}
